<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            font-size: 30px;
            color: red;
        }
    </style>
</head>
<body>
    <div>

    </div>
    <script>
        var  div = document.querySelector('div');
        var newYear = new Date(2021,1,1,0,0,0).getTime();
        console.log(newYear);
        var timer = setInterval(function(){
            var now = new Date().getTime();
            var shiCha = newYear - now;
            if(shiCha <= 0){
                window.clearInterval(timer);
                return;

            }

            var ri = Math.floor(shiCha/(1000*24*60*60));
            var shi = Math.floor(shiCha/(1000*60*60))%24;
            var fen = Math.floor(shiCha/(1000*60))%60;
            var miao = Math.floor(shiCha/1000)%60;
            var hao = Math.floor(shiCha)%1000;
            var str = ri + '天' + shi + '小时' + fen + '分钟' + miao + '秒' + hao + '毫秒';
            div.innerHTML = str;
        },10)
            

        

       /*  function getTimes(times){
            var nian = times.getFullYear();
            var yue = times.getMonth() + 1;
            var ri = times.getDate();
            var zhou = times.getDay();
            var shi = times.getHours();
            var fen = times.getMinutes();
            var miao = times.getSeconds();
            yue < 10?yue = '0' + yue:yue;
            ri < 10?ri = '0' + ri:ri;
            shi < 10?shi = '0' + shi:shi;
            fen < 10?fen = '0' + fen:fen;
            miao < 10?miao = '0' + miao:miao;
            return nian + '/' + yue + "/" + ri + ' ' + shi + ':' + fen + ':' + miao;

        }
        var times = new Date();
        var t = getTimes(times)
        console.log(t);
        var a = setInterval */
    </script>
</body>
</html>